//
//  StringToAttribStringTransformer.m
//  Cabinet
//
//  Created by Florent Montsegur on 23/08/12.
//
//

#import "StringToAttribStringTransformer.h"

@implementation StringToAttribStringTransformer

+ (Class)transformedValueClass
{
    return [NSAttributedString class];
}

+ (BOOL)allowsReverseTransformation
{
	return YES;
}

/*
 * Transform NSString to NSAttributedString
 *
 */
- (id)transformedValue:(id)value
{
    if(value == nil)
        return nil;
    
    NSAttributedString* attribString = [[NSAttributedString alloc] initWithString:(NSString*)value];
    return attribString;
}

/*
 * Transform NSAttributedString to NSString
 *
 */
- (id)reverseTransformedValue:(id)value
{
	if(value==nil)
		return nil;
    
	return [(NSAttributedString*)value string];
}


@end
